<template>
	<view>
		<view class="item themeBac cwhite f-c">
			<image :src="url" mode="widthFix"></image>
			<input type="tel" @input="inputMo" :value="oldPass" placeholder="请输入原密码" />
		</view>

		<view class="item themeBac cwhite f-c">
			<image :src="url" mode="widthFix"></image>
			<input type="number" :value="newPass" @input="inputCode" placeholder="请输入新密码" />
		</view>
		
		<view class="item themeBac cwhite f-c">
			<image :src="url" mode="widthFix"></image>
			<input type="number" :value="newPassAgain" @input="inputCode2" @blur="blurAgain" placeholder="请再次输入新密码" />
		</view>

		<view class="btn">
			<button @click="toNext" class="themeBac cwhite">确定修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldPass: "",
				newPass: "",
				newPassAgain: "",
				url:'../../static/my/icon_xgmm.png'
			}
		},
		methods: {
			inputMo(v){
				this.oldPass=v.detail.value
			},
			inputCode(v){
				this.newPass=v.detail.value
			},
			inputCode2(v){
				this.newPassAgain=v.detail.value
			},
			blurAgain(v){
				console.log(v);
				if(v.detail.value!=this.newPass){
					this.$u.toast("密码不匹配！")
				}
			},
			async toNext() {
				if(this.newPassAgain!=this.newPass){
					this.$u.toast("两次密码不一致！")
					return;
				}
				const res=await this.$u.api.updatePwd({
					id:this.vuex_user.id,
					newPwd:this.newPass,
					oldPwd:this.oldPass
				})
				console.log(res);
				if(!res.success){
					this.$u.toast(res.msg)
					return;
				}
				this.$redirec('../register/register')
			}
		}
	}
</script>

<style>
	.item {
		margin: 30rpx 80rpx;
		border-radius: 10rpx;
		padding: 17rpx;
	}

	.item image {
		width: 30rpx;
		margin-right: 20rpx;
	}

	.item input {
		border-left: 4rpx solid #FFFFFF;
		padding-left: 20rpx;
	}

	.input-placeholder {
		font-size: 28rpx;
		color: #FFFFFF;
	}

	.getCode {
		white-space: nowrap;
		border-left: 4rpx solid #FFFFFF;
		padding-left: 10rpx;
		font-size: 28rpx;
	}

	.btn {
		margin: 100rpx 80rpx;
	}
</style>
